function Subscribe() {
    this.subscribers = [];
    this.events = {};
}

Subscribe.prototype.publish = function (type, data) {
    var events = this.events[type];
    if (isArray(events)) {
        events.forEach(function (subEvent) {
            isFun(subEvent) && subEvent(data);
        });
    }
}

Subscribe.prototype.subscribe = function (type, cb) {
    if (isArray(this.events[type])) {
        this.events[type].push(cb);
    } else {
        this.events[type] = [cb];
    }
}

Subscribe.prototype.fire = function (type, cb) {
    if (isArray(this.events[type])) {
        this.events[type] = removeItemInArray(cb, this.events[type]);
    }
}
